<template>
	<view :style="themeColor">
		<view class="page">
			<!---flex布局flex布局开始-->
			<view class="flex flex-direction flex-wrap align-start justify-center benben-flex-layout denglu_flex_0">
				<view class='flex flex-wrap align-center justify-center denglu_fd0_0'>
					<view class='flex flex-wrap align-center denglu_fd0_0_c0'>
						<image class='denglu_fd0_0_c0_c0' mode="aspectFit" src='https://paiaifalv.oss-cn-beijing.aliyuncs.com/images/logo.png'></image>
					</view>
					<view class='flex flex-wrap align-center justify-center denglu_fd0_0_c1'>
						<text class='denglu_fd0_0_c1_c0'>案网</text>
					</view>
				</view>
				<!-- <text class='denglu_fd0_1'>申请获取以下权限</text>
				<text class='denglu_fd0_2'>获取你的公开信息（昵称、头像、地区等）</text> -->
				<view class='flex flex-wrap align-center justify-center denglu_fd0_3' @click="loginclick" v-if="xianshidata==1">
					<!-- <image class='denglu_fd0_3_c0' mode="aspectFit" src='https://paiaifalv.oss-cn-beijing.aliyuncs.com/images/49.png'></image> -->
					<text class='denglu_fd0_3_c1'>快捷键登录</text>
				</view>
				<view v-if="xianshidata==2" class='flex flex-wrap align-center justify-center login_fd1_2'>
					<!-- <image class='login_fd1_2_c0' mode="aspectFit" :src='STATIC_URL+"3.png"'></image> -->
					<button type="default" style="background-color: rgba(38, 191, 1, 1);color: #fff;font-size: 32rpx; width: 686rpx;border-radius:8rpx;margin-top: 32rpx;"
						open-type="getPhoneNumber" @getphonenumber="decryptPhoneNumber">手机号快捷登录</button>
				</view>
				<view class='flex flex-wrap align-center flex-sub' style="position: fixed;bottom: 88rpx;width:650rpx;left:50rpx;">
					<view class='flex flex position-relative align-center' v-if="ischeck" @click="checkclick">
						<image class='denglu_checkfd0_4_c0_c0_c0' mode="aspectFit" src='https://paiaifalv.oss-cn-beijing.aliyuncs.com/images/50.png'>
						</image>
					</view>
					<view class='flex flex position-relative justify-end align-center' v-else  @click="checkclick">
						<image class='denglu_noCheckfd0_4_c0_c1_c0' mode="aspectFit" src='https://paiaifalv.oss-cn-beijing.aliyuncs.com/images/51.png'>
						</image>
					</view>
					<text class='denglu_fd0_4_c1'>注册登录即同意</text>
					<text class='denglu_fd0_4_c2' @click="nextpage(19)">《用户注册协议》</text>
					<text class='denglu_fd0_4_c3'>和</text>
					<text class='denglu_fd0_4_c2' @click="nextpage(20)">《隐私政策》</text>
				</view>
			</view>
			<!---flex布局flex布局结束-->
		</view>
		
		<view class="juese" v-if="jueseshow">
			<view class="juese_content">
				<view class="juese_content_one">
					<view class="juese_content_one_header">
						<text>请选择你的角色</text>
					</view>
					<view class="juesulist" v-for="item in tigonglist" :class="{'juesulist_now':tgid==item.aid}" @click="tgclick(item.aid)">
						<text>{{item.name}}</text>
					</view>
					<view class="juese_bottom">
						<view class="juese_bottom_l" @click="canceclick">
							<text>取消</text>
						</view>
						<view class="juese_bottom_r" @click="canfirem">
							<text>确定</text>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
	export default {
		components: {},


		data() {
			return {
				ischeck:false,
				xianshidata: 1, //手机授权登录的弹窗
				tigonglist:[],//服务提供者
				tgid:"",//选择的ID
				jueseshow:false,//角色弹窗
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},

		},
		watch: {},
		onLoad(options) {
			this.post65e95d10b2cbc();
		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {

		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			//服务提供者
			post65e95d10b2cbc(){
				this.$api.post(global.apiUrls.post65e95d10b2cbc, {
					
				}).then(res => {
					if (res.data.code == 1) {
						this.tigonglist = res.data.data;
					}else{
						this.$message.info(res.data.msg);
					}
				})
			},
			
			//提供选择事件
			tgclick(id){
				this.tgid = id;
			},
			
			//取消事件
			canceclick(){
				this.tgid = "";
				this.jueseshow = false;
				uni.switchTab({
					url:"/pages/tabBar/shouye/shouye"
				})
			},
			
			//确定事件
			canfirem(){
				this.jueseshow = false;
				this.$api.post(global.apiUrls.post5cb54af125f1c, {
					user_level_id: this.tgid,
				}).then(res=>{
					if(res.data.code==1){
						uni.switchTab({
							url:"/pages/tabBar/shouye/shouye"
						})
					}else{
						this.$message.info(res.data.msg);
					}
				})
			},
			
			//
			checkclick(){
				this.ischeck = !this.ischeck;
			},
			
			//跳转
			nextpage(type){
				uni.navigateTo({
					url:"/pages/xtsz/helpDetails/helpDetails?id="+type,
				})
			},
			
			//登录点击事件
			loginclick(){
				let _this = this;
				if(this.ischeck==false){
					this.$message.info("请先阅读协议和隐私政策")
					return
				}else{
					uni.login({
						provider: 'weixin',
						success: (res) => {
							_this.code = res.code;
							_this.$api.post(global.apiUrls.user_social_login, {
								third_type: "wx_miniapp",
								code: res.code,
							}).then(res1 => {
								console.log(res1)
								if (res1.data.code == 99) {
									_this.wxinfo = res1.data.data.result;
									_this.xianshidata = 2;
								} else if (res1.data.code == 1) {
									uni.setStorageSync("token", res1.data.data.userinfo.user_token);
									if(res1.data.data.userinfo.userlevel_id==0){
										_this.jueseshow = true;
										return
									}else{
										setTimeout(function(){
											uni.switchTab({
												url:"/pages/tabBar/shouye/shouye"
											})
										},500)
									}
								} else {
									_this.$message.info(msg)
								}
							})
						}
					})
				}
			},
			
			//获取手机号码登录方法
			decryptPhoneNumber(e) {
				let _this = this;
				uni.login({
					provider: 'weixin',
					success: function(res) {
						_this.$api.post(global.apiUrls.post5d7757d28d076, {
							third_type:"wx_miniapp",
							account_type:"mobile",
							code: res.code,
							openid:_this.wxinfo.openid,
							iv: e.detail.iv,
							encrypteddata:e.detail.encryptedData,
						}).then(etr => {
							if (etr.data.code == 1) {
								uni.setStorageSync("token", etr.data.data.userinfo.user_token)
								// setTimeout(function(){
								// 	uni.switchTab({
								// 		url:"/pages/tabBar/shouye/shouye"
								// 	})
								// },500)
								if(etr.data.data.userinfo.userlevel_id==0){
									_this.jueseshow = true;
									return
								}else{
									setTimeout(function(){
										uni.switchTab({
											url:"/pages/tabBar/shouye/shouye"
										})
									},500)
								}
							}else{
								uni.showToast({
									title: etr.data.msg,
									icon: 'none',
									duration: 2000
								});
							}
						}).catch((err) => {
							console.log(err);
						});
					}
				});
			},
		}
	};
</script>
<style lang="scss" scoped>
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: #eeeeee;
		background-size: 100% auto;
	}

	.denglu_flex_0 {
		padding: 0rpx 32rpx 0rpx 32rpx;
	}

	.denglu_fd0_4_c3 {
		font-size: 24rpx;
		font-weight: 400;
		color: rgba(102, 102, 102, 1);
		line-height: 32rpx;
		margin: 0rpx 15rpx 0rpx 15rpx;
	}

	.denglu_fd0_4_c2 {
		font-size: 24rpx;
		font-weight: 400;
		color:#26bf01;
		line-height: 32rpx;
	}

	.denglu_fd0_4_c1 {
		font-size: 24rpx;
		font-weight: 400;
		color: rgba(102, 102, 102, 1);
		line-height: 32rpx;
		margin: 0rpx 15rpx 0rpx 20rpx;
	}

	.denglu_noCheckfd0_4_c0_c1_c0 {
		border-radius: 24rpx 24rpx 24rpx 24rpx;
		width: 32rpx;
		height: 32rpx;
	}

	.denglu_checkfd0_4_c0_c0_c0 {
		width: 32rpx;
		height: 32rpx;
		border-radius: 24rpx 24rpx 24rpx 24rpx;
	}

	::v-deep .denglu_fd0_4_c0 {
		margin: 0rpx 8rpx 0rpx 0rpx;
	}

	.denglu_fd0_3_c1 {
		line-height: 45rpx;
		font-size: 32rpx;
		font-weight: 500;
		color: #FFFFFF;
	}

	.denglu_fd0_3_c0 {
		width: 44rpx;
		height: 36rpx;
		margin: 0rpx 14rpx 0rpx 0rpx;
	}

	.denglu_fd0_3 {
		background: rgba(38, 191, 1, 1);
		width: 686rpx;
		height: 88rpx;
		border-radius: 8rpx;
		margin: 0rpx 0rpx 44rpx 0rpx;
	}

	.denglu_fd0_2 {
		line-height: 40rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #999999;
		margin: 0rpx 24rpx 56rpx 24rpx;
	}

	.denglu_fd0_1 {
		line-height: 45rpx;
		font-size: 32rpx;
		font-weight: 400;
		color: #333333;
		margin: 0rpx 24rpx 16rpx 24rpx;
	}

	.denglu_fd0_0_c1_c0 {
		color: #3F5B39;
		font-size: 40rpx;
		font-weight: 400;
		line-height: 0rpx;
	}

	.denglu_fd0_0_c1 {
		width: 100%;
		height: 200rpx;
	}

	.denglu_fd0_0_c0_c0 {
		width: 100%;
		height: 100%;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}

	.denglu_fd0_0_c0 {
		width: 132rpx;
		height: 152rpx;
	}

	.denglu_fd0_0 {
		width: 100%;
		margin: 0300rpx 0rpx 60rpx 0rpx;
	}
	.juese{
		width: 100%;
		height: 100%;
		position: fixed;
		left: 0;
		top: 0;
		background-color: rgba(0, 0, 0, 0.5);
	}
	.juese_content{
		width: 100%;
		overflow: hidden;
		position: absolute;
		left: 0;
		bottom: 0;
		background-color: #FFFFFF;
		border-radius: 32rpx 32rpx 0 0;
	}
	.juese_content_one{
		width: 662rpx;
		overflow: hidden;
		margin: 0 auto;
		text-align: center;
	}
	.juese_content_one_header{
		font-weight: 600;
		font-size: 32rpx;
		color: #333333;
		padding-top: 38rpx;
		padding-bottom:88rpx;
	}
	.juesulist{
		width: 100%;
		height:140rpx;
		background: #EFEFEF;
		border-radius: 8rpx;
		margin-bottom: 22rpx;
		font-weight: 500;
		font-size:28rpx;
		color: #333333;
		line-height: 140rpx;
	}
	.juesulist_now{
		background: #C7EFBD;
	}
	.juese_bottom{
		width: 100%;
		overflow: hidden;
		line-height: 98rpx;
		margin-top: 88rpx;
		margin-bottom: 44rpx;
	}
	.juese_bottom_l{
		width:320rpx;
		height:98rpx;
		background: #EEF2ED;
		border-radius: 8rpx;
		font-weight: 500;
		font-size:28rpx;
		color: #333333;
		float: left;
	}
	.juese_bottom_r{
		width:320rpx;
		height:98rpx;
		background: #26BF01;
		border-radius:8rpx;
		float: right;
		font-weight: 500;
		font-size:28rpx;
		color: #FFFFFF;
	}
</style>